package com.ktjiaoyu.service.impl;

import com.ktjiaoyu.mapper.VideoMapper;
import com.ktjiaoyu.pojo.Video;
import com.ktjiaoyu.service.VideoService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class VideoServiceImpl implements VideoService {
    @Resource
    VideoMapper videoMapper;

    @Override
    public List<Video> selectPage(String category, Long languageId, Integer pageNo, Integer pageSize) {
        Integer pageBegin=(pageNo-1)*pageSize;
        return videoMapper.selectPage(category,languageId,pageBegin,pageSize);
    }

    @Override
    public Integer selectCount(String category, Long languageId) {
        return videoMapper.selectCount(category,languageId);
    }

    @Override
    @Transactional
    public int insert(Video video) {
        return videoMapper.insert(video);
    }

    @Override
    public Video selectOne(Long id) {
        return videoMapper.selectOne(id);
    }

    @Override
    @Transactional
    public int update(Video video) {
        return videoMapper.update(video);
    }

    @Override
    @Transactional
    public int delete(Long id) {
        return videoMapper.delete(id);
    }
}
